﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using RoutingDaemon;
using System.Threading;

namespace IRCPhase2Tester.Daemons
{
    class LocalRoutingDaemon:DaemonBase
    {
        public RoutingDaemon.RoutingDaemon routingDaemon;
        Thread thread;

        public LocalRoutingDaemon(int nodeID, string configurationFileName):base(nodeID,configurationFileName)
        {

        }

        public override void Start()
        {

            string[] args = new string[] { "-i", this.NodeID.ToString(), "-c", this.ConfigurationFileName };
            routingDaemon = new RoutingDaemon.RoutingDaemon(this.NodeID,IRC.Utilities.ConfigFileParser.LoadConfigurationFromPath(this.ConfigurationFileName));
            thread = new Thread(new ThreadStart(routingDaemon.Start));
            thread.Start();

        }

        public override void Suspend()
        {
            if (thread != null)
                thread.Abort();
        }

        public override void Kill()
        {
            if (routingDaemon != null)
                routingDaemon.Shutdown();
        }

        public override void Silence()
        {
            routingDaemon.Silence();
        }

        public override void Unsilence()
        {
            routingDaemon.Unsilence();
        }
    }
}
